﻿using System;
using System.Collections.Generic;
using STeaL.Functional;

namespace STeaL.Algorithm {
  public static partial class IListExtensions {
#region replace_if
    public static void replace_if<T>(this IList<T> list, int first, int last, Func<T,bool> pred, T val) {
      for ( ; first != last; ++first ) {
        if ( pred(list[first]) ) list[first] = val;
      }
    }

    public static void replace_if<T>(this IList<T> list, Func<T,bool> pred, T val) {
      replace_if(list, 0, list.Count, pred, val);
    }

#endregion
  }
}
